package com.aliyun.test.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @version v1.0
 * @Date:2024-03-19
 * @Description: TODO
 * @Author: yuteng
 */
@Controller
public class MyController {
    @Value("${lesson}")
    private String lesson;
    @Value("${server.port}")
    private String port;
    @Value("${class.ruangong01}")
    private String ruangong01;
    @Value("${class.ruangong02}")
    private String ruangong02;
    @Value("${class.ruangong03}")
    private String ruangong03;
    @Value("${class.ruangong04}")
    private String ruangong04;
//    @Value("${course}")
//    private List<String> course;

    @Value("SpringBoot")
    private String course;
    @Autowired
    private Environment env;

    @Autowired
    private Course course1;


    @RequestMapping("/hello")
    public String testMyController() {
        System.out.println("于腾");
        System.out.println("访问一班写的SpringBoot应用");
        System.out.println("访问到控制器！");
        System.out.println("获取到的配置文件单层级:"+ lesson);
        System.out.println("获取到的配置文件二层:"+ port);
        System.out.println("获取到的配置文件数组:"+ course);
        System.out.println("使用ENV获取到的配置文件数组:"+ env.getProperty("lesson"));
        System.out.println("获取到的配置文件数组:"+ env.getProperty("server.port"));
        System.out.println("获取到的配置文件数组:"+ env.getProperty("class.course[1]"));
        System.out.println("获取到的配置文件数组:"+ course1.getCourse()[1]);
        return "获取到的配置文件："+port;
    }
    @RequestMapping("/hello1")
    public String testMyController1() {
        System.out.println("展示网页");
        return "hello.html";
    }
}
